Previous Book Contents Book Index Next

Inside Macintosh: Open Transport /
Chapter 3 - Endpoints / Endpoints Reference
Functions / Obtaining Information About an Endpoint


OTGetProtAddress

Obtains the address to which an endpoint is bound and, if the endpoint is currently connected, obtains the address of its peer.

C INTERFACE
OSStatus OTGetProtAddress (EndpointRef ref, TBind* boundAddr,
                           TBind* peerAddr)
C++ INTERFACE
OSStatus TEndpoint::GetProtAddress (TBind* boundAddr,
                                    TBind* peerAddr);
PARAMETERS
ref
The endpoint reference of the endpoint whose local and peer address is sought.
boundAddr
A pointer to a TBind structure (page 3-51). The boundAddr->addr field is a TNetBuf structure that describes the address of the endpoint specified by the ref parameter. You must allocate a buffer for the address information and
initialize the addr.buf field to point to that buffer. You must also initialize the addr.maxlen field to the maximum size of
the address.
If you are calling this function only to determine the address of the peer endpoint, you can set the boundAddr parameter to NIL.
The boundAddr->qlen field is ignored.
peerAddr
A pointer to a TBind structure (page 3-51). If the endpoint specified by the ref parameter is currently connected, the peerAddr->addr field is a TNetbuf structure that describes
the address of the endpoint's peer. The boundAddr->qlen field
is ignored.
DESCRIPTION
The OTGetProtAddress function returns the address to which an endpoint is bound in the boundAddr parameter and, if the endpoint is currently connected, the address of its peer in the peerAddr parameter. Not all endpoints support this function. A value of T_XPG4_1 in the flags field of the TEndpointInfo structure indicates that the endpoint does support this function.

You are responsible for initializing the buffers required to hold the local and peer addresses. The addr field of the TEndpointInfo structure specifies the maximum amount of memory needed to store the address of an endpoint. Use this value to set the size of the buffers.

The information returned by the OTGetProtAddress function is affected by the state of the endpoint specified by the ref parameter. If the endpoint is in the T_UNBND state, the boundAddr->addr.len field is set to 0. If the endpoint is not in the T_DATAXFER state, the peerAddr->addr.len field is set to 0.

If the endpoint is in asynchronous mode and a notifier is not installed, it is not possible to determine when the function completes.

COMPLETION EVENT CODES
T_GETPROTADDRCOMPLETE0x20000008The OTGetProtAddress function has completed. The cookie parameter of the notifier function contains the peerAddr parameter unless it is nil, in which case the cookie parameter contains the boundAddr parameter.
VALID STATES
All

SEE ALSO
The TBind structure (page 3-51) describes the address to which an endpoint
is bound.

The flags field of the TEndpointInfo structure (page 3-45) indicates whether the endpoint supports this function.

For information on how to use this function with a TCP/IP protocol, see page 8-17 in the TCP/IP chapter.

For more information about the peer endpoint, see the description of the OTAccept function (page 3-127).


Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 AUG 1996